using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Xml;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ExecuteXmlReaderPage : System.Web.UI.Page
{
     
    protected void Page_Load(object sender, EventArgs e)
    {
        string connectionString =
                    WebConfigurationManager.ConnectionStrings[
                    "RCVDB2000"].ConnectionString;
        SqlConnection sqlConnection;
        SqlCommand sqlCommand;        
        sqlConnection = new SqlConnection();
        sqlConnection.ConnectionString =
        connectionString;
        try
        {
            sqlConnection.Open();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText =
            "select * from tblJobCategories"
            + "  for XML Auto ";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType = CommandType.Text;
            XmlReader xmlReader
            = sqlCommand.ExecuteXmlReader();
            Literal1.Text="";
            while (xmlReader.Read())
            {
                Literal1.Text +=Convert.ToString(
                xmlReader.GetAttribute(
                "JobCategoryName")) +"<br>";
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
        catch (Exception ex)
        {
            Literal1.Text += "Failed:" + ex.Message;
        }
        sqlConnection.Dispose();
    }
}
